#This should be the first line of the CMakeLists.txt
cmake_minimum_required(VERSION 3.14)

# Poor practice, but very common
project(live555)

if (WIN32)
    set(CMAKE_CXX_STANDARD 20)
    add_definitions(
        -D_CRT_SECURE_NO_WARNINGS
        -D_WINSOCK_DEPRECATED_NO_WARNINGS
        -DNO_GETIFADDRS
        -DNO_OPENSSL
    )
else()
    add_definitions(
        -DSOCKLEN_T=socklen_t 
        -D_LARGEFILE_SOURCE=1 
        -D_FILE_OFFSET_BITS=64
    )
endif()

add_subdirectory(liveMedia)
add_subdirectory(groupsock)
add_subdirectory(BasicUsageEnvironment)
add_subdirectory(UsageEnvironment)


file(GLOB USER_LIBS_FILE ./mediaServer/*.cpp)
add_executable(live555MediaServer
        ${USER_LIBS_FILE})   

#add_definitions("-std=c++11 -O -DSOCKLEN_T=socklen_t -g -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -DBSD=1")
#add_compile_options(-std=c++11 -O -DSOCKLEN_T=socklen_t -g -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -DBSD=1)

target_link_libraries(live555MediaServer
        PRIVATE liveMedia
        PRIVATE groupsock
        PRIVATE BasicUsageEnvironment
        PRIVATE UsageEnvironment
        PRIVATE Ws2_32
      )

target_include_directories(live555MediaServer 
        PUBLIC .
        PUBLIC include
        PUBLIC UsageEnvironment/include
        PUBLIC groupsock/include
        PUBLIC liveMedia/include
        PUBLIC BasicUsageEnvironment/include)

# proxy live555
add_executable(live555ProxyServer proxyServer/live555ProxyServer.cpp)  
target_link_libraries(live555ProxyServer
        PRIVATE liveMedia
        PRIVATE groupsock
        PRIVATE BasicUsageEnvironment
        PRIVATE UsageEnvironment
        PRIVATE Ws2_32
      )
target_include_directories(live555ProxyServer 
        PUBLIC .
        PUBLIC include
        PUBLIC UsageEnvironment/include
        PUBLIC groupsock/include
        PUBLIC liveMedia/include
        PUBLIC BasicUsageEnvironment/include)
# hls live555
add_executable(live555HLSProxy hlsProxy/live555HLSProxy.cpp)  
target_link_libraries(live555HLSProxy
        PRIVATE liveMedia
        PRIVATE groupsock
        PRIVATE BasicUsageEnvironment
        PRIVATE UsageEnvironment
        PRIVATE Ws2_32
      )
target_include_directories(live555HLSProxy 
        PUBLIC .
        PUBLIC include
        PUBLIC UsageEnvironment/include
        PUBLIC groupsock/include
        PUBLIC liveMedia/include
        PUBLIC BasicUsageEnvironment/include)

